<template>
  <div>
    <h2>登陆状态与统计</h2>
    <div>
      <p>登陆用户</p>
      <img :src="loginUser.face" width="50" height="50">
      用户名：{{ loginUser.username }}<br>
      邮箱:{{ loginUser.email }}
    </div>
    <div>
      <p>频道</p>
      <table border="1" width="100%" cellspacing="1">
        <thead>
        <tr>
          <th>频道名称</th>
          <th>频道描述</th>
          <th>主贴数量</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="ch in channelList" :key="ch.id">
          <td><router-link :to="{name:'Post',query:{channelId:ch.id}}">{{ch.name}}</router-link></td>
          <td>{{ch.description}}</td>
          <td>{{ch.postNum}}</td>
        </tr>
        </tbody>
      </table>
      <div id="channelCut"></div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      loginUser: {},
      faceImg: "/project/face/",
      channelList: []
    }
  }, created() {
    this.findLoginUser();
    this.showChannel();
    this.faceImg += this.loginUser.face;
  }, methods: {
    findLoginUser() {
      axios.get("/project/user/findLoginUser").then(resp => {
        this.loginUser = resp.data;
        this.loginUser.face="/project/face/"+this.loginUser.face;
      })
    },
    showChannel() {
  axios.get("/project/channel/findAll").then(resp => {
    this.channelList = resp.data;
  })
}
  }
}
</script>

<style scoped>

</style>